package com.wandian.setting.mvvm.senddynamic;

import android.os.Bundle;
import android.view.View;

import androidx.databinding.DataBindingUtil;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.StatusBarUtils;
import com.mylib.libcore.utils.ToastUtil;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.setting.R;
import com.wandian.setting.databinding.SetActivityModifyPasswordBinding;
import com.wandian.setting.databinding.SetActivitySendDynamicBinding;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description  发布动态
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_SETTING_SEND_DYNAMIC)
public class SendDynamicActivity extends  BaseMVVMActivity<SendDynamicViewModel>  {
    private SetActivitySendDynamicBinding dataBinding;
    private String title = "";
    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.set_activity_send_dynamic);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        title = getIntent().getStringExtra("title");
        initViewData();
        initClink();
    }
    private void initViewData(){
        //设置状态颜色和字体黑色
        StatusBarUtils.with(this,false)
                .setIsActionBar(false)
                .clearActionBarShadow()
                .setDrawable(getResources().getDrawable(com.mylib.libcore.R.drawable.sys_color))
                .init();
        dataBinding.bindSysToolBar.toolBarTvTitle.setText(title+"");

        dataBinding.bindSysToolBar.toolBarTitleRight.setText("提交");
        dataBinding.bindSysToolBar.toolBarTitleRight.setVisibility(View.VISIBLE);

    }
    private void initClink(){
        dataBinding.bindSysToolBar.toolBarIvBack.setOnClickListener(v -> {
            finishhideSoftBoard();
            finish();
        });
        dataBinding.bindSysToolBar.toolBarTitleRight.setOnClickListener(v -> {
            finishhideSoftBoard();
            if(UIUtils.isEmpty(dataBinding.etContent.getText())){
                ToastUtil.show("请写点什么在提交吧");
                return;
            }
            switch (title){
                case "动态":
                    mViewModel.sendDT(dataBinding.etContent.getText().toString(), "");
                    break;
                case "树洞":
                    mViewModel.sendSD(dataBinding.etContent.getText().toString(), "");
                    break;
            }

        });

    }

    @Override
    protected void onDestroy() {
        finishhideSoftBoard();
        super.onDestroy();
    }
}
